// 2680. 最大或值
// AC: https://leetcode.cn/problems/maximum-or/submissions/613588053/

class Solution {
public:
    typedef long long ll;
    long long maximumOr(vector<int>& nums, int k) {
        int n=nums.size();
        ll sum=0,mat=0;
        for(auto x:nums){
            mat|=x&sum;
            sum|=x;
        }
        ll ans=0;
        for(auto x:nums){
            ans=max(ans,(sum^x)|(1ll*x<<k)|mat);
        }
        return ans;
    }
};